﻿#ifndef FINANCESTANDARDITEMMODEL_H
#define FINANCESTANDARDITEMMODEL_H

#include <QStandardItemModel>
#include "dingdananddetail.h"

class FinanceStandardItemModel : public QStandardItemModel
{
    Q_OBJECT
public:
    explicit FinanceStandardItemModel(QObject *parent = nullptr);

    bool setData(const QModelIndex &index, const QVariant &value, int role) override;

    QVariant data(const QModelIndex &index, int role) const override;

    QStringList header;

    void reset();

    void refresh();

    void setWidgetType(Dingdan::FinanceWidgetType widgetType);

    void insertDingdanDetail(DingdanAndDetail &detail);

    void insertDingdanDetail(QList<DingdanAndDetail*> details);

    double totalFinanceMake();

    double totalFinanceNeed();

    QList<DingdanDetail*> validDingdanDetail();

    void financeAllocate(double totalFinance);//分配金额
signals:
    void updateTotal(double totalFinance);

public slots:

private:
    Dingdan::FinanceWidgetType widgetType;

    QList<DingdanDetail*> details;
};

#endif // FINANCESTANDARDITEMMODEL_H
